<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
    <link rel="stylesheet" href="../../images/table.css" type="text/css"></link>
  	<script type="text/javascript" src="../../js/jquery-1.8.2.js"></script>
  	<script type="text/javascript" src="../../js/jquery.form.js"></script>
  	<script type="text/javascript" src="../../js/ajaxfileupload.js"></script> 
    <script type="text/javascript" src="../../js/tableScoll.js"></script>
    <script type="text/javascript" src="../../js/inbound.js"></script> 
    <script type="text/javascript" src="../../js/Calendar3.js"></script>
    <script type="text/javascript" src="../../js/ajaxSearch.js"></script> 
    <style>
		#searchresult{width:302px; position:absolute; left:618px; top:180px; 
		z-index:1; overflow:hidden; background:#dcf6f8; border:#c5dadb 1px solid;
		border-top:none;
		}
		.line{font-size:12px; color:#000; background:#aed34f; width:302px; padding:2px;}
		.hover{background:#007ab8; color:#fff;}
	</style>
</head>
  <body>
    <form id="inboundCreateForm"  action="../../inboundAction_saveInboundList.action" method="post">
   <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="../../images/mail_leftbg.gif"><img src="../../images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="../../images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">入库单发起</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="../../images/mail_rightbg.gif"><img src="../../images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="../../images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
    	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	      <tr>
	        <td colspan="10" valign="top">
	      		<!--  控件按钮栏-->
		         <TABLE class=main_tab id=mainTable cellSpacing=0 cellPadding=0 width=100% border=0>
		            <tr>
		                <td>
	                 	 <input type="button" name="inboundCreate"  id="inboundCreate"  value="入库单发起"  onclick="uploadfile()"/>
	                	</td>
		             </tr>		      
		             <tr>		             	
						<td>入库执行人：</td>           
						<td><input type="text" name="adminSearch" id="adminSearch" />
							<input type="hidden" name="inboundForm.stExector" id="stExector" />
						</td>
						<td>入库单关联编号:</td>
						<td><input type="text" name="inboundForm.stInboundNo" id="stInboundNo" /></td>         
		             </tr>
		             <tr><td><br/></td></tr>
		             <tr>
		             	<td>入库单发起时间：</td>
		             	<td><input type="text" name="inboundForm.stStartTime" id="stStartTime" onclick="new Calendar().show(this);"/>
		             		<input type="button"  style="background-image:url(../../images/calendar.png);width:32;height:32"  
		             		onclick="new Calendar().show(this.form.stStartTime);" />
		             	</td>         
						<td>入库单截止时间：</td>
						<td><input type="text" name="inboundForm.stEndTime" id="stEndTime" onclick="new Calendar().show(this);"/>
							<input type="button"  style="background-image:url(../../images/calendar.png);width:32;height:32"  
		             		onclick="new Calendar().show(this.form.stEndTime);" />
						</td>  
		             </tr>
			      </TABLE>
		     </td>
		     <td>&nbsp;</td>
		  </tr>
		  <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
		  </tr>
		  <tr>
		 	 <td colspan="5">
              	<input type="button"  name="submitImport" id="submitImport" value="导入"  />
              	<input type="button"  name="arrayClear"  id="arrayClear"  value="清空"/>
              	<input type="hidden" name="array"  id="array"  />
             </td>
             <td>
             </td>
		  </tr>
		  <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
		  </tr>
		  <tr>
		  	 <td colspan="20">
		  	 	<div style="overflow:scroll; height:300px; width:1100px;">
				    <table class="tab_data"  id="dataTable" >  
				       <tr id="title">
				            <th>序号</th>
					       	<th>设备序列号</th>
							<th>设备型号</th>
							<th>设备位置</th>
							<th>设备所处商户</th>
							<th>设备单价</th>
							<th>设备合同号</th>
							<th>设备合同维护人</th>
							<th>设备厂商</th>
							<th>设备出场时间</th>
							<th>设备状态</th>
				       </tr>
				 	</table>
				 	</div>
		        </td>
		  </tr>
		  <!-- 翻页工具  -->
	      <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
	      </tr>
	      <tr>
	        <td width="2%">&nbsp;</td>
	        <td width="51%" class="left_txt"><img src="../../images/icon-mail2.gif" width="16" height="11"> <br>
	              <img src="../../images/icon-phone.gif" width="17" height="14"> </td>
	        <td>&nbsp;</td>
	        <td>&nbsp;</td>
	      </tr>
	</table>
    </td>
    <td background="../../images/mail_rightbg.gif">&nbsp;</td>
</tr>
<tr>
   <td valign="bottom" background="../../images/mail_leftbg.gif"><img src="../../images/buttom_left2.gif" width="17" height="17" /></td>
   <td background="../../images/buttom_bgs.gif"><img src="../../images/buttom_bgs.gif" width="17" height="17"></td>
   <td valign="bottom" background="../../images/mail_rightbg.gif"><img src="../../images/buttom_right2.gif" width="16" height="17" /></td>
</tr>
</table>
 </form>
  </body>
  <script type="text/javascript">
	function submitForm(){  
		var stStartTime = document.getElementById("stStartTime").value;
		var stEndTime = document.getElementById("stEndTime").value;
		var stExector = document.getElementById("stExector").value;
		var form = document.getElementById("inboundCreateForm"); 
		
		if(stStartTime == null || stStartTime==""){
			alert("入库发起时间不能为空！");
			return;
		}
		if(stEndTime == null || stEndTime== ""){
			alert("入库结束时间不能为空！");
			return;
		}
		if(stExector == null || stExector==""){
			alert("执行人不能为空！");
			return;
		}
		if(stStartTime > stEndTime){
			alert("入库结束时间不能为小于入库发起时间！");
			return;
		}
		form.submit();   
    }
	
	
    function loadExcelFileInfo(){
    	var params = "array=" + document.getElementById("array").value;
    	$.ajax({  
	      url:'../../inboundAjax_loadInboundFile.action',
	      data:params,
	      type:'post',  
	      dataType:'json',  
	      success: function(data){
       		if(data !=null){
		 		if(data.message != null && data.result == null){
		 			alert(data.message);
		 		}else{
		 			if(data.result != null){
		 				 alert("导入成功！");
		 				 var list = data.result;
			 			 $.each(list,function(m,bean) {
			 				var row = "<tr class=dataArea><td>" + (m+1)+"</td>" ;
							row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stSnNumber id=_clist  value=" + bean.stSnNumber +" /> </td>";
							row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stStoreType id=_clist  value=" + bean.stStoreType +" /> </td>";
							row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stStoreLocation id=_clist  value=" + bean.stStoreLocation +" /> </td>";
							if(bean.stMerchant == null || bean.stMerchant == ""){
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stMerchant id=_clist/> </td>";	
							}else{
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stMerchant id=_clist  value=" + bean.stMerchant +" /> </td>";	
							}
							
							if(bean.stStorePrice == null || bean.stStorePrice == ""){
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stStorePrice id=_clist/> </td>";
							}else{
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stStorePrice id=_clist  value=" + bean.stStorePrice +" /> </td>";	
							}
							
						 	if(bean.stContactNumber == null || bean.stContactNumber == ""){
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stContactNumber id=_clist/> </td>";
							}else{
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stContactNumber id=_clist  value=" + bean.stContactNumber +" /> </td>";	
							}
						 	
						 	if(bean.stContactEmployer == null || bean.stContactEmployer == ""){
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stContactEmployer id=_clist/> </td>";
							}else{
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stContactEmployer id=_clist  value=" + bean.stContactEmployer +" /> </td>";	
							}
						 	
						 	if(bean.stFactory == null || bean.stFactory == ""){
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stFactory id=_clist/> </td>";
							}else{
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stFactory id=_clist  value=" + bean.stFactory +" /> </td>";	
							}
						 	
						 	if(bean.stFactoryDate == null || bean.stFactoryDate == ""){
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stFactoryDate id=_clist/> </td>";
							}else{
								row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stFactoryDate id=_clist  value=" + bean.stFactoryDate +" /> </td>";	
							}
						 	
						 	row += "<td><input type=text  name=inboundForm.stInboundList["+m+"].stState id=_clist  value=" + bean.stState +" /> </td>";
							row += "</tr>";
							$("#dataTable").append(row);
			    	 	 });
		 			}
		 		}
	 	 	}else{
	 	 		alert("载入失败！");
	 	 	}
	      }
    	});
	}
</script>
</html>